/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ceair.flight.refund.dto.uatp;

import com.ceair.muservice.common.dto.BaseRes;

import java.io.Serializable;

/**
 *
 * @author youguilin
 */
public class BasicRes extends BaseRes implements Serializable {

    private static final long serialVersionUID = -2537558462249904432L;
    private String code;
    private String msg;

    public BasicRes() {
    }

    public BasicRes(String code) {
        this.code = code;
    }

    public BasicRes(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static BasicRes newInstance(boolean flag) {
        return flag ? newSucessRes() : newFailRes();
    }

    public static BasicRes newInstance(boolean flag, String msg) {
        return flag ? newSucessRes() : newFailRes(msg);
    }

    public static BasicRes newSucessRes() {
        return new BasicRes(ResponseConstants.CODE_SUCCESS);
    }

    public static BasicRes newFailRes() {
        return new BasicRes(ResponseConstants.CODE_FAIL);
    }

    public static BasicRes newFailRes(String msg) {
        return new BasicRes(ResponseConstants.CODE_FAIL, msg);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public boolean isSuccessRes() {
        return ResponseConstants.CODE_SUCCESS.equals(code);
    }

    public boolean isFailRes() {
        return !ResponseConstants.CODE_SUCCESS.equals(code);
    }
}
